home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Dev / ace23.lha / PRGS.lha / IO / print.b < prev    next >
Text File  |  1994-01-10  |  1KB  |  73 lines

  1. { ** Send a file to the printer **
  2.  
  3.   If the program is started from the shell,
  4.   the file name is taken to be the first
  5.   argument. Likewise if the program is
  6.   WorkBench launched. Otherwise the 
  7.   program invokes a file requester. 
  8.  
  9.   If the requested file doesn't exist 
  10.   the program quits with a beep.
  11.  
  12.   Page size can also be specified.
  13. }
  14.  
  15. #include <WBarg.h>
  16.  
  17. DEFINT a-z
  18.  
  19. page_size=0
  20.  
  21. SUB usage
  22.   print "usage: ";arg$(0);" ? | [<filename>][page-size]"
  23. END SUB
  24.  
  25. '..get the filename
  26. if WBargcount=2 then
  27.   '..Workbench args
  28.   x$ = WBargPath$(1) + WBarg$(1)
  29. else
  30.   if argcount > 0 then
  31.     '..CLI/shell args
  32.     if argcount = 1 then
  33.        x$ = arg$(1)
  34.        if x$ = "?" then 
  35.           usage
  36.           stop
  37.        end if
  38.     else
  39.       if argcount = 2 then 
  40.      x$ = arg$(1)
  41.      page_size = val(arg$(2)) 
  42.       else
  43.      '..too many args
  44.          usage
  45.      stop
  46.       end if
  47.     end if
  48.   else
  49.     '..no args
  50.     x$ = FileBox$("Select file to print")
  51.   end if
  52. end if
  53.  
  54. '..print the file
  55. open "I",1,x$
  56.  
  57. if handle(1)=0 then beep:stop  '..doesn't exist.
  58.  
  59. open "O",2,"PRT:"
  60. ln$=""
  61. count=0
  62. while not eof(1)
  63.  line input #1,ln$
  64.  print #2,ln$
  65.  ++count
  66.  if page_size > 0 and count = page_size then 
  67.     count=0
  68.     print #2,chr$(12)  '..form feed
  69.  end if
  70. wend
  71.  
  72. close 1,2
  73.